﻿Imports Arwani
Imports System.Data

Partial Class CouponCode
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim strCode As String = Request.QueryString("ID")
        Dim awrcon As New ArwaniController
     
        Try
            Dim decryptpwd As String = String.Empty
            Dim encodepwd As New UTF8Encoding()
            Dim Decode As Decoder = encodepwd.GetDecoder()
            Dim todecode_byte As Byte() = Convert.FromBase64String(strCode)
            Dim charCount As Integer = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length)
            Dim decoded_char As Char() = New Char(charCount - 1) {}
            Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0)
            decryptpwd = New [String](decoded_char)

            Dim str As String = "Select * from Raffle where Code='" & decryptpwd & "'"
            Dim dtTable As DataTable = awrcon.ExecuteQuery(str)
            If dtTable.Rows.Count > 0 Then
                lblCode.Text = decryptpwd
                getMessage()
            Else
                mainContainer.Visible = False
                lblerror.Text = "You do not have permission to access this page"
            End If
        Catch ex As Exception
            mainContainer.Visible = False
            lblerror.Text = "You do not have permission to access this page"
            ' Throw New Exception(""")
        End Try
    End Sub
    Public Sub getMessage()
        Dim awrcon As New ArwaniController
        Dim str As String = "Select Message from RaffleMaster where ID='1'"
        Dim dtTable As DataTable = awrcon.ExecuteQuery(str)
        If dtTable.Rows.Count > 0 Then
            lblDescription.Text = dtTable.Rows(0)("Message")
        End If
    End Sub


End Class
